Skip to content

🔧 Fix frontmatter hash extraction to support JSON metadata format#17971

Merged
dsyme merged 3 commits intomainfrom
fmh
Feb 23, 2026
Merged

🔧 Fix frontmatter hash extraction to support JSON metadata format#17971
dsyme merged 3 commits intomainfrom
fmh

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Feb 23, 2026

Summary

  • Updates extractHashFromLockFile to first attempt parsing the new JSON metadata format (# gh-aw-metadata: {...}) before falling back to the legacy # frontmatter-hash: <hash> format
  • Adds tests to verify correct hash mismatch detection for both matching and non-matching hashes in the JSON metadata format
  • Minor doc fix clarifying when the GitHub Projects token is required

Copilot AI review requested due to automatic review settings February 23, 2026 19:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates lock-file frontmatter hash extraction to support the newer JSON metadata header format while maintaining backward compatibility with the legacy # frontmatter-hash: line.

Changes:

  • Update extractHashFromLockFile to read # gh-aw-metadata: {...} via workflow.ExtractMetadataFromLockFile, with fallback to legacy parsing.
  • Add a unit test covering hash match/mismatch detection using the JSON metadata format.
  • Clarify docs wording for when the GitHub Projects token is required.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/cli/run_push.go Uses workflow lock metadata parsing to extract frontmatter_hash from JSON metadata, falling back to legacy extraction.
pkg/cli/run_push_test.go Adds coverage ensuring JSON metadata hashes are correctly interpreted for match/mismatch.
docs/src/content/docs/reference/auth.mdx Clarifies “When Required” conditions for the Projects token.
Comments suppressed due to low confidence (3)

pkg/cli/run_push.go:650

  • ExtractMetadataFromLockFile can return a non-nil error for malformed # gh-aw-metadata: {...} JSON, but this code silently ignores that and falls back to legacy parsing. That can lead to misleading observability (e.g., logging "No frontmatter-hash found" even though metadata was present but invalid). Consider logging the metadata parse error (or returning it up to checkFrontmatterHashMismatch) before falling back so failures are visible.
	// First, try to extract from JSON metadata format using the proper workflow package function
	if metadata, _, err := workflow.ExtractMetadataFromLockFile(content); err == nil && metadata != nil {
		if metadata.FrontmatterHash != "" {
			return metadata.FrontmatterHash
		}

pkg/cli/run_push.go:17

  • The import block is split into two internal-package groups (blank line after pkg/stringutil), which is inconsistent with other pkg/cli files (e.g., pkg/cli/access_log.go:10-14) and may get rewritten by goimports. Consider grouping all github.com/github/gh-aw/pkg/... imports together in a single block.
	"github.com/github/gh-aw/pkg/stringutil"

	"github.com/github/gh-aw/pkg/console"
	"github.com/github/gh-aw/pkg/fileutil"
	"github.com/github/gh-aw/pkg/logger"

pkg/cli/run_push_test.go:423

  • This test fixture/comment says the JSON metadata line is "as written by current compiler", but the compiler JSON uses omitempty for stop_time (see pkg/workflow/lock_schema.go:24-28), so an empty stop_time field typically won't be emitted. Consider either omitting stop_time from the test lock content or giving it a non-empty value to better match real output.
	// Create a lock file with JSON metadata format (as written by current compiler)
	// Uses snake_case field names matching the Go struct JSON tags
	lockFilePath := filepath.Join(tmpDir, "test-workflow.lock.yml")
	lockContent := fmt.Sprintf(`# This workflow was auto-generated by gh-aw
#
# gh-aw-metadata: {"schema_version":"v1","frontmatter_hash":"%s","stop_time":""}


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

Hey @dsyme 👋 — thanks for jumping in to fix the frontmatter hash extraction for the new JSON metadata format! The technical changes look solid: you've added tests for both matching and non-matching hashes, updated the extraction logic to handle both formats, and maintained backward compatibility with the legacy format.

However, this repository has a unique contribution process that this PR doesn't follow:

  • Process violation — This project requires all contributions to go through GitHub Copilot Agent. According to CONTRIBUTING.md, traditional pull requests are not enabled. Instead, contributors should:
    1. Open an issue with a detailed agentic plan describing the bug and proposed fix
    2. Wait for maintainer review and approval
    3. Maintainer assigns the issue to GitHub Copilot Agent
    4. Agent creates and implements the PR automatically

Why this matters: This project practices "dogfooding" — using agentic workflows to build agentic workflows. By creating PRs directly, we bypass the very system we're building, which defeats the purpose and prevents us from discovering issues in the agentic workflow process itself.

Next steps: A maintainer will need to decide whether to accept this PR as an exception or ask you to close it and follow the standard agentic contribution process.

Thanks again for the contribution — the fix itself is well-implemented! 🙌

Generated by Contribution Check

@dsyme dsyme merged commit 0cf1c55 into main Feb 23, 2026
90 checks passed
@dsyme dsyme deleted the fmh branch February 23, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants